package com.ruoyi.web.controller.order;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.order.domain.OrderGoodsCombo;
import com.ruoyi.order.service.IOrderGoodsComboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单卖品详情Controller
 *
 * @author HHAOYU
 * @date 2021-01-12
 */
@RestController
@RequestMapping("/order/orderGoodsCombo")
public class OrderGoodsComboController extends BaseController
{
    @Autowired
    private IOrderGoodsComboService orderGoodsComboService;

    /**
     * 查询订单卖品详情列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderGoodsCombo:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderGoodsCombo orderGoodsCombo)
    {
        startPage();
        List<OrderGoodsCombo> list = orderGoodsComboService.selectOrderGoodsComboList(orderGoodsCombo);
        return getDataTable(list);
    }

    /**
     * 导出订单卖品详情列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderGoodsCombo:export')")
    @Log(title = "订单卖品详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderGoodsCombo orderGoodsCombo)
    {
        List<OrderGoodsCombo> list = orderGoodsComboService.selectOrderGoodsComboList(orderGoodsCombo);
        ExcelUtil<OrderGoodsCombo> util = new ExcelUtil<OrderGoodsCombo>(OrderGoodsCombo.class);
        return util.exportExcel(list, "orderGoodsCombo");
    }

    /**
     * 获取订单卖品详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderGoodsCombo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(orderGoodsComboService.selectOrderGoodsComboById(id));
    }

    /**
     * 新增订单卖品详情
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderGoodsCombo:add')")
    @Log(title = "订单卖品详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderGoodsCombo orderGoodsCombo)
    {
        return toAjax(orderGoodsComboService.insertOrderGoodsCombo(orderGoodsCombo));
    }

    /**
     * 修改订单卖品详情
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderGoodsCombo:edit')")
    @Log(title = "订单卖品详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderGoodsCombo orderGoodsCombo)
    {
        return toAjax(orderGoodsComboService.updateOrderGoodsCombo(orderGoodsCombo));
    }

    /**
     * 删除订单卖品详情
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderGoodsCombo:remove')")
    @Log(title = "订单卖品详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderGoodsComboService.deleteOrderGoodsComboByIds(ids));
    }
}
